package com.yunmang.fragment;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.TextView;

import com.yunmang.R;
import com.yunmang.activity.FastOpenOrderActivity;
import com.yunmang.activity.TransportActivity;
import com.yunmang.activity.daohuo.ArriveActivity;
import com.yunmang.activity.exception.ExceptionManager;
import com.yunmang.activity.fache.TransportManager;
import com.yunmang.activity.kaipiaoActivity;
import com.yunmang.activity.ordermanager.OrderManagerActivity;
import com.yunmang.activity.ordermanager.UpdateAndPrintActivity;
import com.yunmang.activity.qianshou.QianshouActivity;
import com.yunmang.activity.trace.OrderTraceActivity;
import com.yunmang.adapter.MyGridViewAdapter;
import com.yunmang.adapter.YingyunAdapter;
import com.yunmang.app.AppConstant;
import com.yunmang.entity.MyItemInfoBean;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * 作者 : bean on 2017/4/5/0005.
 * 注释 :首页
 */
public class HomePageFragment extends BaseFragment implements AdapterView.OnItemClickListener {
    @InjectView(R.id.gridview)
    GridView gridview;
    @InjectView(R.id.tv_title)
    TextView text;
    private YingyunAdapter adapter;
    @Override
    public int getLayoutId() {
        return R.layout.fragment_statement;
    }

    @Override
    public void initView(View view) {
        ButterKnife.inject(this, view);
        gridview.setAdapter(new YingyunAdapter(context));
        gridview.setOnItemClickListener(this);
    }

    @Override
    public void initData(){
        text.setText("业务管理");
    }


    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        if(AppConstant.type.equals("2")){//分拨中心
            switch (i){
                case 0:
                    startActivity(new Intent(getActivity(),FastOpenOrderActivity.class));
                    break;
                case 1:
                    startActivity(new Intent(getActivity(), kaipiaoActivity.class));
                    break;
                case 2:
                    startActivity(new Intent(getActivity(), UpdateAndPrintActivity.class));
                    break;
                case 3:
                    startActivity(new Intent(getActivity(), ArriveActivity.class));
                    break;
                case 4:
                    startActivity(new Intent(getActivity(), TransportActivity.class));
                    break;
                case 5:
                    startActivity(new Intent(getActivity(), OrderTraceActivity.class));
                    break;
                case 6:
                    startActivity(new Intent(getActivity(), ExceptionManager.class));
                    break;
                case 7:
                    startActivity(new Intent(getActivity(), TransportManager.class));
                    break;

            }
        }else if(AppConstant.type.equals("1")){//总公司 = 1,
            switch (i){
                case 0:
                    startActivity(new Intent(getActivity(),FastOpenOrderActivity.class));
                    break;
                case 1:
                    startActivity(new Intent(getActivity(), kaipiaoActivity.class));
                    break;
                case 2:
                    startActivity(new Intent(getActivity(), UpdateAndPrintActivity.class));
                    break;
                case 3:
                    startActivity(new Intent(getActivity(), QianshouActivity.class));
                    break;
                case 4:
                    startActivity(new Intent(getActivity(), TransportActivity.class));
                    break;
                case 5:
                    startActivity(new Intent(getActivity(), ArriveActivity.class));
                    break;
                case 6:
                    startActivity(new Intent(getActivity(), OrderManagerActivity.class));
                    break;
                case 7:
                    startActivity(new Intent(getActivity(), OrderTraceActivity.class));
                    break;
                case 8:
                    startActivity(new Intent(getActivity(), ExceptionManager.class));
                    break;
                case 9:
                    startActivity(new Intent(getActivity(), TransportManager.class));
                    break;
            }
        }else{
            switch (i){
                case 0:
                    startActivity(new Intent(getActivity(),FastOpenOrderActivity.class));
                    break;
                case 1:
                    startActivity(new Intent(getActivity(), kaipiaoActivity.class));
                    break;
                case 2:
                    startActivity(new Intent(getActivity(), UpdateAndPrintActivity.class));
                    break;
                case 3:
                    startActivity(new Intent(getActivity(), QianshouActivity.class));
                    break;
                case 4:
                    startActivity(new Intent(getActivity(), TransportActivity.class));
                    break;
                case 5:
                    startActivity(new Intent(getActivity(), ArriveActivity.class));
                    break;
                case 6:
                    startActivity(new Intent(getActivity(), OrderManagerActivity.class));
                    break;
                case 7:
                    startActivity(new Intent(getActivity(), OrderTraceActivity.class));
                    break;
                case 8:
                    startActivity(new Intent(getActivity(), ExceptionManager.class));
                    break;
                case 9:
                    startActivity(new Intent(getActivity(), TransportManager.class));
                    break;
            }
        }
    }
}
